package com.jy.blog.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jy.blog.model.Article;
import com.jy.blog.service.ArticleService;
import com.jy.blog.service.impl.ArticleServiceImpl;


/**
 * Servlet implementation class SelArticle
 */
public class SelArticle extends HttpServlet {
	private static final long serialVersionUID = 1L;
	 private ArticleService service=new ArticleServiceImpl();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SelArticle() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int id= Integer.valueOf(request.getParameter("id"));
		   Article carticle=service.selectById(id);
		   request.setAttribute("carticle", carticle);
		   request.getRequestDispatcher("selArticle.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
